<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <div>
    <van-sticky>
      <van-nav-bar
        title="订单详情"
        left-text="返回"
        left-arrow
        @click-left="$router.go(-1)"
      />
    </van-sticky>
    <van-collapse v-model="detlist">
      <van-collapse-item :title="item.order_time" :name="item.oid"
      v-for="item in detlist"
      :key="item.oid"
      >
        <div class="fk">
            <van-cell :title="item.user" icon="manager"/>
            <van-cell :title="item.tel" icon="phone"/>
            <van-cell :title="item.address" icon="location"/>
            <van-cell :title="item.total_price" icon="gold-coin"/>
        </div>
        <van-card
        v-for="item in item.goods"
        :key="item.tid"
        :num="item.pnum"
        :price="item.price+'.00'"
        :title="item.tname"
        :thumb="item.timg"
        />
      </van-collapse-item>
    </van-collapse>
  </div>
</template>

<script>
export default {
  data () {
    return {
      detlist: []
    }
  },

  // 接收父组件传递过来的参数
  props: {},

  components: {},

  // computed是计算属性，也就是依赖其它的属性计算所得出最后的值
  computed: {},

  // 页面初始化方法
  mounted () {
    this.getOrderdet()
  },

  // 监听方法 click事件等 ，执行drawFeatures方法
  methods: {
    getOrderdet () {
      const uid = JSON.parse(sessionStorage.getItem('userinfo')).uid
      this.$api.Orderdet({ uid: uid }).then((res) => {
        if (res.data.code === 200) {
          this.detlist = res.data.msg
          this.detlist.sort((a, b) => b.oid - a.oid)
        }
      })
    }
  }
}
</script>
<style lang='less' scoped>
/deep/.van-nav-bar .van-icon{
    color: #a7cd6d;
}
/deep/.van-nav-bar__text{
    color: #a7cd6d;
}
</style>
